package com.xinqi.modules.chat.favorite.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.xinqi.common.mybatis.data.service.impl.BaseServiceImpl;
import com.xinqi.modules.chat.favorite.domain.FavoriteTypeEntity;
import com.xinqi.modules.chat.favorite.mapper.FavoriteTypeMapper;
import com.xinqi.modules.chat.favorite.dto.rsp.FavoriteTypeResultDTO;
import com.xinqi.modules.chat.favorite.convert.FavoriteTypeConvert;
import com.xinqi.modules.chat.favorite.service.FavoriteTypeService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 收藏分类表服务层实现
 *
 * @author: yyzhen
 * @date: 2023/03/23
 */
@Service("favoriteTypeService")
@RequiredArgsConstructor
public class FavoriteTypeServiceImpl extends BaseServiceImpl<FavoriteTypeMapper, FavoriteTypeEntity> implements FavoriteTypeService {
    private final FavoriteTypeConvert favoriteTypeConvert;

    /**
     * 查询收藏分类列表
     *
     * @Title:
     * @MethodName: selectList
     * []
     * @Return java.util.List<com.xinqi.modules.chat.favorite.dto.rsp.FavoriteTypeResultDTO>
     * @Exception
     * @Description:
     * @author: yyzhen
     * @date: 2023/3/23 14:18
     */
    @Override
    public List<FavoriteTypeResultDTO> selectList() {
        LambdaQueryWrapper<FavoriteTypeEntity> wrapper = new LambdaQueryWrapper<>();
        wrapper.orderByAsc(FavoriteTypeEntity::getId);
        return this.baseMapper.selectList(wrapper).stream().map(favoriteTypeConvert::convert).collect(Collectors.toList());
    }
}
